$(function() {

	initpatientTestInfo();

	
	/*渲染题目列表*/
	function getTestList(data){
		if(typeof(data.evaluatingList)  !="undefined"){
			data=data.evaluatingList;
		}
		var html = "";
		for (i in data) {
				html += '<li class="mui-table-view-cell mui-media"><a href="javascript:;" class="intoinfo" data-href="./patient-test1.html?id='+data[i].id+'"><img class="mui-media-object mui-pull-left" src="'+data[i].picurl+'"><div class="mui-media-body"><div class="mui-ellipsis font4">'+data[i].title+'</div><p class="font1"><font>'+data[i].participantcount+'</font>人测试过</p></div></a></li>';
		}
		$(".mui-table-view").empty();
		$(".mui-table-view").prepend(html);
	}
	/*绑定筛选类型*/
	$(".clickList").bind("click",function(){
		var id = $(this).data("id");
		var param = {"pageNo":1,"type":id,"pageSize":999};
		patientTestmodule.patientTest(param,getTestList);
		
	});
	/*绑定 点击 进入详情*/
	$(".intoinfo").live("click",function(){
		var herf = $(this).data("href");
		mui.openWindow({
			url:herf,
		});
		
	});
	/*绑定 点击 进入答题*/
	$(".cilckTest").live("click",function(){
		var herf = $(this).data("href");
		mui.openWindow({
			url:herf,
		});
		
	});
	/*心理自测详情*/
	function initpatientTestInfo(){
		sessionStorage.setItem("status", "1"); 
		var EvaluatingId =utilModule.getQueryString("id");
		var param = {"EvaluatingId":EvaluatingId};
		patientTestmodule.patientTestInfo(param,callBack);
		function callBack(data){
			console.log(data);
			var html = '<div class="patient-img">'+
							'<img src="'+data.picurl+'" style="height: 200px;">'+
						'</div>'+
						'<div class="patient-form font1">'+
							'<span class="mui-pull-left"><img src="../../images/default.png" ><font>馨语医疗-专业精神和心理平台</font></span>'+
							'<span class="mui-pull-right"><font>'+data.participantcount+'</font>人测试过</span>'+
						'</div>'+
						'<h1>'+data.title+'</h1>'+
						'<div class="patient-article font3">'+
							data.explain+
						'</div>'+
						'<div class="patient-start">'+
							'<button data-href="./patient-question.html?id='+data.id+'&qid=0" class="cilckTest">开始测试</button>'+
							'<p class="font1">此测试仅供参考，不做诊断标准</p>'+
						'</div>';
			$("body").empty();
			$("body").prepend(html);
		}
		
	}
	
	
}); 